<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>TechBlog - 重置密码</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            /* 亮色主题变量 */
            --bg-color: #ffffff;
            --text-color: #24292f;
            --border-color: #d0d7de;
            --card-bg: #f6f8fa;
            --header-bg: #f6f8fa;
            --accent-color: #0969da;
            --accent-hover: #0550ae;
            --code-bg: rgba(175, 184, 193, 0.2);
            --shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
            --tag-bg: #ddf4ff;
            --tag-color: #0969da;
            --filter-bg: #f6f8fa;
            --input-bg: #ffffff;
            --error-color: #d73a49;
            --success-color: #28a745;
        }

        .dark-theme {
            /* 深色主题变量 */
            --bg-color: #0d1117;
            --text-color: #e6edf3;
            --border-color: #30363d;
            --card-bg: #161b22;
            --header-bg: #161b22;
            --accent-color: #2f81f7;
            --accent-hover: #1c6bdb;
            --code-bg: rgba(110, 118, 129, 0.4);
            --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.7);
            --tag-bg: #388bfd26;
            --tag-color: #58a6ff;
            --filter-bg: #161b22;
            --input-bg: #0d1117;
            --error-color: #f85149;
            --success-color: #3fb950;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            transition: background-color 0.3s, color 0.3s, border-color 0.3s;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
            background-color: var(--bg-color);
            color: var(--text-color);
            line-height: 1.5;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        .container {
            max-width: 1280px;
            margin: 0 auto;
            padding: 0 20px;
        }

        /* 头部导航 */
        header {
            background-color: var(--header-bg);
            border-bottom: 1px solid var(--border-color);
            position: sticky;
            top: 0;
            z-index: 100;
        }

        .navbar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 16px 0;
            position: relative;
        }

        .logo {
            display: flex;
            align-items: center;
            gap: 10px;
            font-weight: 600;
            font-size: 20px;
            color: var(--text-color);
            text-decoration: none;
            z-index: 101;
        }

        .logo i {
            color: var(--accent-color);
        }

        .nav-links {
            display: flex;
            gap: 24px;
        }

        .nav-links a {
            color: var(--text-color);
            text-decoration: none;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.2s ease;
        }

        .nav-links a:hover {
            color: var(--accent-color);
        }

        .nav-links a.active {
            color: var(--accent-color);
            font-weight: 600;
        }

        .nav-actions {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .theme-toggle {
            background: none;
            border: 1px solid var(--border-color);
            border-radius: 6px;
            padding: 8px 12px;
            color: var(--text-color);
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 14px;
            transition: all 0.2s ease;
        }

        .theme-toggle:hover {
            background-color: var(--code-bg);
        }

        .mobile-menu {
            display: none;
            background: none;
            border: 1px solid var(--border-color);
            border-radius: 6px;
            color: var(--text-color);
            cursor: pointer;
            padding: 8px 12px;
            font-size: 16px;
            transition: all 0.2s ease;
        }

        .mobile-menu:hover {
            background-color: var(--code-bg);
        }

        /* 主要内容区域 */
        .main-content {
            display: flex;
            justify-content: center;
            align-items: center;
            flex: 1;
            padding: 40px 0;
        }

        /* 重置密码表单容器 */
        .reset-password-container {
            width: 100%;
            max-width: 400px;
            padding: 0 20px;
        }

        .reset-password-card {
            background-color: var(--card-bg);
            border: 1px solid var(--border-color);
            border-radius: 6px;
            padding: 32px;
        }

        .reset-password-header {
            text-align: center;
            margin-bottom: 24px;
        }

        .reset-password-header h2 {
            font-size: 24px;
            font-weight: 600;
            margin-bottom: 8px;
        }

        .reset-password-header p {
            color: var(--text-color);
            opacity: 0.8;
            font-size: 14px;
            line-height: 1.5;
        }

        /* 表单样式 */
        .form-group {
            margin-bottom: 16px;
            position: relative;
        }

        .form-label {
            display: block;
            margin-bottom: 6px;
            font-size: 14px;
            font-weight: 500;
        }

        .form-input {
            width: 100%;
            padding: 12px;
            border: 1px solid var(--border-color);
            border-radius: 6px;
            background-color: var(--input-bg);
            color: var(--text-color);
            font-size: 14px;
            transition: border-color 0.2s ease;
        }

        .form-input:focus {
            outline: none;
            border-color: var(--accent-color);
            box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.1);
        }

        .dark-theme .form-input:focus {
            box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.2);
        }

        .password-toggle {
            position: absolute;
            right: 12px;
            top: 38px;
            background: none;
            border: none;
            color: var(--text-color);
            cursor: pointer;
            opacity: 0.7;
        }

        .password-toggle:hover {
            opacity: 1;
        }

        .password-strength {
            height: 4px;
            margin-top: 8px;
            border-radius: 2px;
            background-color: var(--border-color);
            overflow: hidden;
        }

        .password-strength-bar {
            height: 100%;
            width: 0%;
            transition: width 0.3s ease, background-color 0.3s ease;
        }

        .strength-weak {
            background-color: var(--error-color);
            width: 33%;
        }

        .strength-medium {
            background-color: #ffa500;
            width: 66%;
        }

        .strength-strong {
            background-color: var(--success-color);
            width: 100%;
        }

        .btn {
            display: block;
            width: 100%;
            padding: 12px;
            background-color: var(--accent-color);
            color: white;
            border: none;
            border-radius: 6px;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: background-color 0.2s ease;
        }

        .btn:hover {
            background-color: var(--accent-hover);
        }

        .btn:disabled {
            background-color: var(--border-color);
            cursor: not-allowed;
        }

        /* 错误消息 */
        .error-message {
            color: var(--error-color);
            font-size: 13px;
            margin-top: 4px;
            display: none;
        }

        .form-group.error .form-input {
            border-color: var(--error-color);
        }

        .form-group.error .error-message {
            display: block;
        }

        /* 成功消息 */
        .success-message {
            background-color: rgba(40, 167, 69, 0.1);
            border: 1px solid rgba(40, 167, 69, 0.3);
            border-radius: 6px;
            padding: 12px;
            margin-bottom: 16px;
            color: var(--success-color);
            font-size: 14px;
            display: none;
        }

        .dark-theme .success-message {
            background-color: rgba(63, 185, 80, 0.1);
            border-color: rgba(63, 185, 80, 0.3);
        }

        /* 登录链接 */
        .login-link {
            text-align: center;
            font-size: 14px;
            margin-top: 16px;
        }

        .login-link a {
            color: var(--accent-color);
            text-decoration: none;
            font-weight: 500;
        }

        .login-link a:hover {
            text-decoration: underline;
        }

        /* 页脚 */
        footer {
            border-top: 1px solid var(--border-color);
            padding: 32px 0;
            text-align: center;
            font-size: 14px;
            color: var(--text-color);
            opacity: 0.8;
        }

        /* 响应式设计优化 */
        @media (max-width: 768px) {
            .container {
                padding: 0 16px;
            }

            .navbar {
                padding: 12px 0;
            }

            .logo {
                font-size: 18px;
            }

            .nav-links {
                position: absolute;
                top: 100%;
                left: 0;
                width: 100%;
                background-color: var(--header-bg);
                border-top: 1px solid var(--border-color);
                flex-direction: column;
                padding: 16px 20px;
                display: none;
                box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            }

            .nav-links.active {
                display: flex;
            }

            .nav-links a {
                padding: 12px 0;
                border-bottom: 1px solid var(--border-color);
                font-size: 16px;
            }

            .nav-links a:last-child {
                border-bottom: none;
            }

            .mobile-menu {
                display: block;
                min-height: 44px;
                min-width: 44px;
                display: flex;
                align-items: center;
                justify-content: center;
            }

            .theme-toggle,
            .mobile-menu {
                padding: 10px 14px;
            }

            .main-content {
                padding: 24px 0;
            }

            .reset-password-card {
                padding: 24px;
            }

            /* 减少移动端的动画效果 */
            * {
                transition: none;
            }

            /* 保留必要的过渡 */
            .theme-toggle,
            .mobile-menu,
            .nav-links a,
            .btn {
                transition: all 0.2s ease;
            }
        }

        @media (max-width: 480px) {
            .container {
                padding: 0 12px;
            }

            .reset-password-container {
                padding: 0;
            }

            .reset-password-card {
                padding: 20px;
            }
        }
    </style>
</head>

<body class="light-theme">
    <header>
        <div class="container">
            <nav class="navbar">
                <a href="index.html" class="logo">
                    <i class="fas fa-code"></i>
                    TechBlog
                </a>

                <div class="nav-links">
                    <a href="index.html">首页</a>
                    <a href="article-list.html">文章</a>
                    <a href="tutorial-list.html">教程</a>
                    <a href="projects.html">项目</a>
                    <a href="about.html">关于</a>
                </div>

                <div class="nav-actions">
                    <button class="theme-toggle" id="themeToggle">
                        <i class="fas fa-moon"></i>
                        <span>深色模式</span>
                    </button>
                    <button class="mobile-menu" id="mobileMenu">
                        <i class="fas fa-bars"></i>
                    </button>
                </div>
            </nav>
        </div>
    </header>

    <div class="main-content">
        <div class="container">
            <div class="reset-password-container">
                <div class="reset-password-card">
                    <div class="reset-password-header">
                        <h2>重置密码</h2>
                        <p>请输入您的新密码，确保密码强度足够安全。</p>
                    </div>

                    <div class="success-message" id="successMessage">
                        <i class="fas fa-check-circle"></i> 密码重置成功！正在跳转到登录页面...
                    </div>

                    <form id="resetPasswordForm">
                        <div class="form-group">
                            <label for="newPassword" class="form-label">新密码</label>
                            <input type="password" id="newPassword" class="form-input" placeholder="请输入新密码" required>
                            <button type="button" class="password-toggle" id="newPasswordToggle">
                                <i class="far fa-eye"></i>
                            </button>
                            <div class="password-strength">
                                <div class="password-strength-bar" id="passwordStrength"></div>
                            </div>
                            <div class="error-message" id="newPasswordError">密码至少8个字符，包含字母和数字</div>
                        </div>

                        <div class="form-group">
                            <label for="confirmPassword" class="form-label">确认密码</label>
                            <input type="password" id="confirmPassword" class="form-input" placeholder="请再次输入新密码"
                                required>
                            <button type="button" class="password-toggle" id="confirmPasswordToggle">
                                <i class="far fa-eye"></i>
                            </button>
                            <div class="error-message" id="confirmPasswordError">两次输入的密码不一致</div>
                        </div>

                        <button type="submit" class="btn" id="resetBtn">重置密码</button>
                    </form>

                    <div class="login-link">
                        想起密码了？ <a href="login.html">返回登录</a>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <footer>
        <div class="container">
            <p>© 2023 TechBlog. 保留所有权利。</p>
            <p>采用 Github 风格设计 | 由开发者为开发者打造</p>
        </div>
    </footer>

    <script>
        // 主题切换功能
        const themeToggle = document.getElementById('themeToggle');
        const themeIcon = themeToggle.querySelector('i');
        const themeText = themeToggle.querySelector('span');

        // 检查本地存储的主题偏好
        const currentTheme = localStorage.getItem('theme') || 'light';
        if (currentTheme === 'dark') {
            document.body.classList.add('dark-theme');
            themeIcon.classList.remove('fa-moon');
            themeIcon.classList.add('fa-sun');
            themeText.textContent = '浅色模式';
        }

        themeToggle.addEventListener('click', () => {
            document.body.classList.toggle('dark-theme');

            if (document.body.classList.contains('dark-theme')) {
                themeIcon.classList.remove('fa-moon');
                themeIcon.classList.add('fa-sun');
                themeText.textContent = '浅色模式';
                localStorage.setItem('theme', 'dark');
            } else {
                themeIcon.classList.remove('fa-sun');
                themeIcon.classList.add('fa-moon');
                themeText.textContent = '深色模式';
                localStorage.setItem('theme', 'light');
            }
        });

        // 移动端菜单切换
        const mobileMenu = document.getElementById('mobileMenu');
        const navLinks = document.querySelector('.nav-links');
        const menuIcon = mobileMenu.querySelector('i');

        mobileMenu.addEventListener('click', () => {
            navLinks.classList.toggle('active');

            if (navLinks.classList.contains('active')) {
                menuIcon.classList.remove('fa-bars');
                menuIcon.classList.add('fa-times');
            } else {
                menuIcon.classList.remove('fa-times');
                menuIcon.classList.add('fa-bars');
            }
        });

        // 点击菜单外区域关闭菜单
        document.addEventListener('click', (e) => {
            if (!e.target.closest('.navbar') && navLinks.classList.contains('active')) {
                navLinks.classList.remove('active');
                menuIcon.classList.remove('fa-times');
                menuIcon.classList.add('fa-bars');
            }
        });

        // 窗口大小变化时调整菜单状态
        window.addEventListener('resize', () => {
            if (window.innerWidth > 768) {
                navLinks.classList.remove('active');
                menuIcon.classList.remove('fa-times');
                menuIcon.classList.add('fa-bars');
            }
        });

        // 密码重置表单验证
        const resetPasswordForm = document.getElementById('resetPasswordForm');
        const newPasswordInput = document.getElementById('newPassword');
        const confirmPasswordInput = document.getElementById('confirmPassword');
        const newPasswordToggle = document.getElementById('newPasswordToggle');
        const confirmPasswordToggle = document.getElementById('confirmPasswordToggle');
        const newPasswordError = document.getElementById('newPasswordError');
        const confirmPasswordError = document.getElementById('confirmPasswordError');
        const passwordStrength = document.getElementById('passwordStrength');
        const resetBtn = document.getElementById('resetBtn');
        const successMessage = document.getElementById('successMessage');

        // 密码显示/隐藏切换
        function setupPasswordToggle(toggleBtn, passwordInput) {
            toggleBtn.addEventListener('click', () => {
                const type = passwordInput.getAttribute('type') === 'password' ? 'text' : 'password';
                passwordInput.setAttribute('type', type);
                toggleBtn.innerHTML = type === 'password' ? '<i class="far fa-eye"></i>' : '<i class="far fa-eye-slash"></i>';
            });
        }

        setupPasswordToggle(newPasswordToggle, newPasswordInput);
        setupPasswordToggle(confirmPasswordToggle, confirmPasswordInput);

        // 密码强度检测
        function checkPasswordStrength(password) {
            let strength = 0;
            const strengthBar = passwordStrength;

            // 重置样式
            strengthBar.className = 'password-strength-bar';

            if (password.length === 0) {
                return;
            }

            // 长度检查
            if (password.length >= 8) strength++;

            // 包含小写字母
            if (/[a-z]/.test(password)) strength++;

            // 包含大写字母
            if (/[A-Z]/.test(password)) strength++;

            // 包含数字
            if (/[0-9]/.test(password)) strength++;

            // 包含特殊字符
            if (/[^A-Za-z0-9]/.test(password)) strength++;

            // 根据强度设置样式
            if (strength <= 2) {
                strengthBar.classList.add('strength-weak');
            } else if (strength <= 4) {
                strengthBar.classList.add('strength-medium');
            } else {
                strengthBar.classList.add('strength-strong');
            }
        }

        // 验证新密码
        function validateNewPassword() {
            const password = newPasswordInput.value;
            const passwordGroup = newPasswordInput.closest('.form-group');
            const passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d@$!%*#?&]{8,}$/;

            if (password === '') {
                passwordGroup.classList.add('error');
                newPasswordError.textContent = '密码不能为空';
                return false;
            }

            if (!passwordRegex.test(password)) {
                passwordGroup.classList.add('error');
                newPasswordError.textContent = '密码至少8个字符，包含字母和数字';
                return false;
            }

            passwordGroup.classList.remove('error');
            return true;
        }

        // 验证确认密码
        function validateConfirmPassword() {
            const password = newPasswordInput.value;
            const confirmPassword = confirmPasswordInput.value;
            const confirmPasswordGroup = confirmPasswordInput.closest('.form-group');

            if (confirmPassword === '') {
                confirmPasswordGroup.classList.add('error');
                confirmPasswordError.textContent = '请确认密码';
                return false;
            }

            if (password !== confirmPassword) {
                confirmPasswordGroup.classList.add('error');
                confirmPasswordError.textContent = '两次输入的密码不一致';
                return false;
            }

            confirmPasswordGroup.classList.remove('error');
            return true;
        }

        // 实时验证
        newPasswordInput.addEventListener('input', function () {
            validateNewPassword();
            checkPasswordStrength(this.value);
        });

        confirmPasswordInput.addEventListener('input', validateConfirmPassword);

        // 表单提交
        resetPasswordForm.addEventListener('submit', (e) => {
            e.preventDefault();

            const isNewPasswordValid = validateNewPassword();
            const isConfirmPasswordValid = validateConfirmPassword();

            if (isNewPasswordValid && isConfirmPasswordValid) {
                // 模拟密码重置过程
                resetBtn.disabled = true;
                resetBtn.textContent = '重置中...';

                // 模拟API调用延迟
                setTimeout(() => {
                    successMessage.style.display = 'block';

                    // 3秒后跳转到登录页面
                    setTimeout(() => {
                        window.location.href = 'login.html';
                    }, 3000);
                }, 1500);
            }
        });
    </script>
</body>

</html>